/*
addToAny is a command for sharing any website through AddToAny (http://www.addtoany.com).
addToAny is a refinement from the original 'AddToAny' command from: http://gist.github.com/102242.

addToAny can be executed in Ubiquity by typing:

addToAny to {service name}, where {service name} is any popular social media sharing site such as digg, reddit, delicious, stumpble upon, etc. Refer to addToAny website for a list of supported sharing sites (http://www.addtoany.com/share_save?linkname=AddToAny&linkurl=http%3A//www.addtoany.com/).

addToAny has been tested with Ubiquity 0.5.4 with mozilla firefox 3.5.8 under Ubuntu Linux 9.10.
*/

CmdUtils.CreateCommand({
  names: ["addToAny"],
  homepage: "http://zfranciscus.wordpress.com",
  author: {name:"zainul franciscus"},
  licence: "Creative Common Licence Attribution-Noncommercial-No Derivative Works 3.0 New Zealand (http://creativecommons.org/licenses/by-nc-nd/3.0/nz/)",
  icon: "http://static.addtoany.com/buttons/share_16_16.png",
  description: "Share to any service",
  arguments: [{role: 'object', nountype: noun_type_url, label:'site to share'},
              {role: 'goal', nountype: noun_arb_text, label:'sharing service'}],
  execute: function (arguments) {

    var baseUrl = 'http://www.addtoany.com/add_to/';
    var sharingSite = arguments.goal.text;
    var urlToShare = arguments.object.text;
    var docName = CmdUtils.getDocument().title;

    var sharingURL = baseUrl + sharingSite + "?linkurl=" + urlToShare + "&linkname=" + docName;

    Utils.openUrlInBrowser(sharingURL);
  }
})
 